@model T2.Logging.ASPMVC.ViewModel.LogViewModel
@using T2.Logging.ASPMVC.Entity.Interface          
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <title>@Model.Title</title>
</head>
<body>
	<script type="text/javascript">
	    jQuery(document).ready(function() {
	        var options = {
	            beforeSubmit: validate,  // pre-submit callback
	            success: showResponse  // post-submit callback 
	           
	        };

	        // bind form using 'ajaxForm' 
	        $('#updatelog').ajaxForm(options);
	       	$('#output1').hide();
	        $('#message').hide();
	        function validate(formData, jqForm, options) {
	           var form = jqForm[0];
	           var myList = $('#output1');
			   myList.empty();
				 if (!isNumeric(form.Priority.value)) {
				myList.append("<li>Please enter a number for Priority.</li>");
				};
				 if (isEmpty(form.Severity.value)) {
				myList.append("<li>Please enter a value for Severity.</li>");
				};
				 if (isEmpty(form.Title.value)) {
				myList.append("<li>Please enter a value for Title.</li>");
				};
				 if (isEmpty(form.MachineName.value)) {
				myList.append("<li>Please enter a value for Machine Name.</li>");
				};
				 if (isEmpty(form.AppDomainName.value)) {
				myList.append("<li>Please enter a value for App Domain Name.</li>");
				};
				 if (isEmpty(form.Message.value)) {
				myList.append("<li>Please enter a value for Message.</li>");
				};
				 if (!isNumeric(form.ApplicationID.value)) {
				myList.append("<li>Please enter a number for Application I D.</li>");
				};
				 if (!isNumeric(form.LogCategoryID.value)) {
				myList.append("<li>Please enter a number for Log Category I D.</li>");
				};
				 if (isEmpty(form.Application.value)) {
				myList.append("<li>Please enter a value for Application.</li>");
				};
				 if (isEmpty(form.LogCategory.value)) {
				myList.append("<li>Please enter a value for Log Category.</li>");
				};
				if(!isNumeric(form.Priority.value)|| isEmpty(form.Severity.value)|| isEmpty(form.Title.value)|| isEmpty(form.MachineName.value)|| isEmpty(form.AppDomainName.value)|| isEmpty(form.Message.value)|| !isNumeric(form.ApplicationID.value)|| !isNumeric(form.LogCategoryID.value)|| isEmpty(form.Application.value)|| isEmpty(form.LogCategory.value)){
	                $('#output1').show();
	                $('#message').hide();
	                return false;
	            };

	        };

	       function showResponse(responseText, statusText, xhr, $form) {
	            if (responseText == "true") {
	                $('#message').text("Your update succeeded");
	            }
	            else {
	                $('#message').text("Your update was not successful");
	            }
	            $('#message').show();
	            $('#output1').hide();
	            return true;
	        };

	        function showError(XHRResponse, statusText, error) {

	            if (statusText == "error") {
	                $('#message').text("An error has occured in your application! The error is " + error.toString());
	            }
	            else if (statusText == "timeout") {
	                $('#message').text("The server has timed out! Please try again later.");

	            }
	            else {
	                $('#message').text(error);
	                $('#message').show();
	                $('#output1').hide();
	            }
	            return false;
	        };

	        $('#resetlog').click(function(event) {
	            $('#updatelog').clearForm();
				$('#message').hide();
	            $('#output1').hide();
	        });

				        $('span.ui-dialog-title').text('Modify Log');
			$('input:radio').button();
			$('input:submit').button();
	        $('input:button').button();


	    });
	    
	
	</script>

    <div>
	
	
		<ul class="ui-state-error"  id="output1" style="width:400px"></ul>
		<ul id="message" style="width:400px; height:25px; background-color:Blue; color:White"></ul>
    	<form action="./Log/Update/" id="updatelog" method="post" name="updatelog" >
			<div class="formSection ui-widget-content ui-corner-all">
                <div class="ui-widget-header">
			        <span>@Model.Header</span>
		        </div>
<div id="Empty" class="fullSection">
			<div class="">
			<span>Priority</span>
			<span><input type="text" id="Priority" name="Priority" value="@Model.Model.Priority.ToString()" /></span>
			</div>
			<div class="">
			<span>Severity</span>
			<span><input type="text" id="Severity" name="Severity" value="@Model.Model.Severity.ToString()" /></span>
			</div>
			<div class="">
			<span>Title</span>
			<span><input type="text" id="Title" name="Title" value="@Model.Model.Title.ToString()" /></span>
			</div>
			<div class="">
			<span>Machine Name</span>
			<span><input type="text" id="MachineName" name="MachineName" value="@Model.Model.MachineName.ToString()" /></span>
			</div>
			<div class="">
			<span>App Domain Name</span>
			<span><input type="text" id="AppDomainName" name="AppDomainName" value="@Model.Model.AppDomainName.ToString()" /></span>
			</div>
			<div class="">
			<span>Message</span>
			<span><input type="text" id="Message" name="Message" value="@Model.Model.Message.ToString()" /></span>
			</div>
			<div class="">
			<span>Application I D</span>
			<span><input type="text" id="ApplicationID" name="ApplicationID" value="@Model.Model.ApplicationID.ToString()" /></span>
			</div>
			<div class="">
			<span>Log Category I D</span>
			<span><input type="text" id="LogCategoryID" name="LogCategoryID" value="@Model.Model.LogCategoryID.ToString()" /></span>
			</div>
			<div class="">
			<span>Application</span>
			<span>
			<select  id='ApplicationID' name='ApplicationID'>
			@foreach (IApplication_ui item in Model.Application_List)
			{
			if (Model.Model.ApplicationID == item.ApplicationID)
			{
			<option label="@item.ApplicationID.ToString()" selected="selected" value="@item.ApplicationID.ToString()" >@item.ApplicationID.ToString()</option>
			}
			else
			{
			<option label="@item.ApplicationID.ToString()" value="@item.ApplicationID.ToString()" >@item.ApplicationID.ToString()</option>
			}
			}
			</select>
			</span>
			</div>
			<div class="">
			<span>Log Category</span>
			<span>
			<select  id='LogCategoryID' name='LogCategoryID'>
			@foreach (ILogCategory_ui item in Model.LogCategory_List)
			{
			if (Model.Model.LogCategoryID == item.LogCategoryID)
			{
			<option label="@item.LogCategoryID.ToString()" selected="selected" value="@item.LogCategoryID.ToString()" >@item.LogCategoryID.ToString()</option>
			}
			else
			{
			<option label="@item.LogCategoryID.ToString()" value="@item.LogCategoryID.ToString()" >@item.LogCategoryID.ToString()</option>
			}
			}
			</select>
			</span>
			</div>
			</div>
			<div class="fullSection">
			<span><input id="submitlog" type="submit" value="Submit" /><input id="resetlog" type="button" value="Reset" /></span>
			</div>
			
			</div>
        </div>
		</form>
    
</body>
</html>